package com.futao.springbootlearn20220224.filterdemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.stereotype.Service;

/**
 * @author futao@gmail.com
 * @date 2022/3/28
 */
@Service
public class OtherService {

    /**
     * 这种注入方式会失败，因为Filter已经被Spring包装成FilterRegistrationBean
     */
    // @Autowired
    // private InjectFilter injectFilter;

    /**
     * 注入Filter需要使用包装类型注入，且beanName为Filter的全限定类名，便于区分各个Filter
     */
    @Qualifier("com.futao.springbootlearn20220224.filterdemo.InjectFilter")
    @Autowired
    private FilterRegistrationBean<InjectFilter> injectFilterFilterRegistrationBean;
}
